const TokenKey = 'App-Token'
const User_Id = 'User-Id'
const Dept_Id = 'Dept-Id'
const DeptKey = 'DEPT-LIST'

export function getToken() {
  return uni.getStorageSync(TokenKey)
}

export function setToken(token) {
  return uni.setStorageSync(TokenKey, token)
}

export function removeToken() {
  return uni.removeStorageSync(TokenKey)
}

export function getUserId() {
  return uni.getStorageSync(User_Id)
}

export function setUserId(UserId) {
  return uni.setStorageSync(User_Id, UserId)
}
export function getDeptId() {
  return uni.getStorageSync(Dept_Id)
}

export function setDeptId(UserId) {
  return uni.setStorageSync(Dept_Id, UserId)
}
export function setApptoken(appToken) {
  return uni.setStorageSync("APP_TOKEN", appToken)
}
export function getApptoken() {
  return uni.getStorageSync("APP_TOKEN");
}

export function getIsLeader() {
  return uni.getStorageSync("isleader")
}

export function setIsleader(isLeader) {
  return uni.setStorageSync("isleader", isLeader)
}

export function getUsername() {
  return uni.getStorageSync("username")
}

export function setUsername(username) {
  return uni.setStorageSync("username", username)
}

export function getDeptList() {
  return  getJSON(DeptKey)
}

export function setDeptList(deptList) {
  return uni.setStorageSync(DeptKey, deptList)
}
function getJSON (key) {
  const value = uni.getStorageSync(key)
  if (value != null) {
    return JSON.parse(value)
  }
}
